<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
    <input >
</body>
<script>
    
    function handleClick(){
        console.log("这是测试！")
    };

    /**
     * 思路是点n秒内只执行一次函数
     * */
    function debounce(fn,wait){
        let lastTime = null;
        
        let i = 1;
    
            /* 函数节流 */
            //(1)判断两次触发事件的时间间隔
            let time = Date.now()
            if( time - lastTime >= 500 ){
                console.log('鼠标移动次数：' + i++);
                //(2)本次触发时间作为下一次参考间隔
                lastTime = time
            }
        
}

    
window.addEventListener("click",debounce(handleClick,1000));
</script>
</html> 
